﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="Phoenix.Service.Model" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
编辑新闻
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadStyles" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="HeadScripts" runat="server">
     <script charset="utf-8" src="/Scripts/kindeditor/kindeditor-min.js" type="text/javascript"></script>
    <script charset="utf-8" src="/Scripts/kindeditor/lang/zh_CN.js" type="text/javascript"></script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% NewsModel objNews = ViewData["NewsModel"] as NewsModel;%>
    <% List<NewsCatalogModel> CatalogList = ViewData["CatalogList"] as List<NewsCatalogModel>; %>
<div class="pd10">
        <form id="mainform" method="post" action="save">
        <input type="hidden" id="hdaction" name="hdaction" value="<%=(objNews!=null)?"2":"1" %>" />
        <input type="hidden" id="hdnewsid" name="hdnewsid" value="<%=(objNews!=null)?objNews.NewsID : 0 %>" />

        <table class="tb-list mt10">
            <tr>
                <td class="aR">
                    分类：
                </td>
                <td class="aL">
                    <select id="sltCatalogID" name="sltCatalogID">
                        <%foreach (var item  in CatalogList)%>
                        <%{%>
                        <% if (objNews != null && item.CatalogID == objNews.CatalogID) %>
                            <%{%>
                            <option value="<%=item.CatalogID %>" selected="selected"><%=item.CatalogName%></option>
                            <%}%>
                        <%else %>
                            <%{ %>
                            <option value="<%=item.CatalogID %>"><%=item.CatalogName%></option>
                            <%} %>
                        <%}%>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="aR">
                    标题：
                </td>
                <td class="aL">
                    <input type="text" name="txtTitle" id="txtTitle" value="<%=(objNews!=null)?objNews.Title:"" %>" maxlength="200" style="width: 350px" class="inputStyle" />
                </td>
            </tr>
            <tr>
                <td class="aR">
                    操作：
                </td>
                <td class="aL">
                    显示<input id="IsShow" name="IsShow" type="checkbox" <%=(objNews!=null)?objNews.DisplayFlag.ToString():"" %> />
                </td>
            </tr>
             <tr>
                <td class="aR">
                    关键词：
                </td>
                <td class="aL">
                <input  type="text" name="txtKeywords" id="txtKeywords" value="<%=(objNews!=null)?objNews.Keywords:"" %>" style="width: 350px" class="inputStyle" />

                </td>
            </tr>
             <tr>
                <td class="aR">
                    简介：
                </td>
                <td class="aL">
                <input  type="text" name="txtDescription" id="txtDescription" value="<%=(objNews!=null)?objNews.Description:"" %>" style="width: 350px" class="inputStyle" />

                </td>
            </tr>
            <tr>
                <td class="aR">
                    内容：
                </td>
                <td class="aL">
                    <textarea name="txtContent" id="txtContent" style="width: 100%; height: 350px;" ><%=(objNews != null) ? objNews.Content : ""%></textarea>
                </td>
            </tr>
              <tr>
                <td class="aR">
                    发布时间：
                </td>
                <td class="aL">
                    <input  type="text" name="txtCreateTime" id="txtCreateTime" value="<%=(objNews!=null)?objNews.CreateTime.ToString():"" %>" style="width: 350px" class="inputStyle" />
                </td>
            </tr>
        </table>
        <div class="aC">
            <input name="save" value="保存" type="button" class="a-btn1" />
            <input name="clear" value="清空" id="clear" type="button" class="a-btn1" /></div>
        </form>
    </div>
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="BodyScripts" runat="server">
    <script type="text/javascript">
        var editor;
        KindEditor.ready(function (K) {
            editor = K.create('#txtContent', {
                uploadJson: '/upload/news',
                allowFileManager : false
        	});
        	K('input[name=save]').click(function (e) {

        		if (editor.text() == "") {
        			alert('请输入新闻内容!');
        			return false;
        		}

        		$("#txtContent").val(editor.html());
        		$("#mainform").submit();
        	});

        	K('input[name=clear]').click(function (e) {

        		editor.html('');
        	});
        });
    </script>
</asp:Content>
